package com.cowin.base.result;

/**
 * Copyright (C), 1998-2018, 奇瑞信息
 *
 * @author : 于超
 * @Date: 2019/8/29 17:17
 * @Description:
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static Result genSuccessResult() {
        return new Result()
                .setCode(200)
                .setData("")
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static Result genSuccessResult(Object data) {
        return new Result()
                .setCode(200)
                .setMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static Result genFailResult(String message) {
        return new Result()
                .setCode(400)
                .setData("")
                .setMessage(message);
    }

    public static Result genUnauthorized() {
        return new Result()
                .setCode(401)
                .setData("")
                .setMessage("您没有权限，认证失败！");
    }

    public static Result genUnauthorized(String message) {
        return new Result()
                .setCode(401)
                .setData("")
                .setMessage(message);
    }
}
